-use std::collections::HashSet;
+use std::collections::{HashMap, HashSet};
use std::fs::{self, File};
use std::io::prelude::*;
use std::io;
use std::path::{Path, PathBuf};
-use core::{Package,Manifest,SourceId};
+use core::{Package, Manifest, SourceId, PackageId};
use util::{self, CargoResult, human, Config, ChainError};
use util::important_paths::find_project_manifest_exact;
use util::toml::{Layout, project_layout};
pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
-> CargoResult<Vec<Package>> {
- let mut all_packages = HashSet::new();
+ let mut all_packages = HashMap::new();
let mut visited = HashSet::<PathBuf>::new();
trace!("looking for root package: {}, source_id={}", path.display(), source_id);
if all_packages.is_empty() {
Err(human(format!("Could not find Cargo.toml in `{}`", path.display())))
} else {
- Ok(all_packages.into_iter().collect())
+ Ok(all_packages.into_iter().map(|(_, v)| v).collect())
}
}
}
fn read_nested_packages(path: &Path,
- all_packages: &mut HashSet<Package>,
+ all_packages: &mut HashMap<PackageId, Package>,
source_id: &SourceId,
config: &Config,
visited: &mut HashSet<PathBuf>) -> CargoResult<()> {
let manifest = try!(find_project_manifest_exact(path, "Cargo.toml"));
let (pkg, nested) = try!(read_package(&manifest, source_id, config));
- all_packages.insert(pkg);
+ all_packages.insert(pkg.package_id().clone(), pkg);
// Registry sources are not allowed to have `path=` dependencies because
// they're all translated to actual registry dependencies.
{compiling} b v0.5.0 ([..])
", compiling = COMPILING)));
});
+
+test!(override_and_depend {
+ let p = project("foo")
+ .file("a/a1/Cargo.toml", r#"
+ [project]
+ name = "a1"
+ version = "0.5.0"
+ authors = []
+ [dependencies]
+ a2 = { path = "../a2" }
+ "#)
+ .file("a/a1/src/lib.rs", "")
+ .file("a/a2/Cargo.toml", r#"
+ [project]
+ name = "a2"
+ version = "0.5.0"
+ authors = []
+ "#)
+ .file("a/a2/src/lib.rs", "")
+ .file("b/Cargo.toml", r#"
+ [project]
+ name = "b"
+ version = "0.5.0"
+ authors = []
+ [dependencies]
+ a1 = { path = "../a/a1" }
+ a2 = { path = "../a/a2" }
+ "#)
+ .file("b/src/lib.rs", "")
+ .file("b/.cargo/config", r#"
+ paths = ["../a"]
+ "#);
+ p.build();
+ assert_that(p.cargo("build").cwd(p.root().join("b")),
+ execs().with_status(0)
+ .with_stdout(&format!("\
+{compiling} a2 v0.5.0 ([..])
+{compiling} a1 v0.5.0 ([..])
+{compiling} b v0.5.0 ([..])
+", compiling = COMPILING)));
+});